# -*- coding: utf-8 -*-
# @Time    : 2019/11/8 17:57
# @Author  : Jinwei
# @File    : read_xlxs.py

from openpyxl import load_workbook
#from main_start import excel_path
from config.config import *



def read_xlsx(path=None):
    # 1、打开Excel
    workbook = load_workbook(filename=excel_path + excel_file_name)
    # 2、定位表单
    sheet = workbook['Sheet1']
    # 3、操作excel的case表单
    # 1、根据行列读取数据
    # data1 = sheet.cell(2, 3).value
    # print(data1)

    # # 4、获取所有列 col 、所有行 row
    target_name = []
    max_row = sheet.max_row
    for row in range(2, max_row + 1):
        test_case = sheet.cell(row, 3).value
        if test_case == yaml_file_name:
            target_name.append(row)
    return [sheet,target_name[0],workbook]
    #     sheet.cell(row, 5).value = json.loads(login)["info"] + json.loads(login)["error_info"]
    #
    # # 将测试结果保存
    # workbook.save("openpyxl_test.xlsx")